<template>
  <div>
    <div class="pay-container">
      <Alert show-icon>
        扫码支付
        <Icon type="qr-scanner" slot="icon"></Icon>
        <template slot="desc">请扫描右边二维码进行支付</template>
      </Alert>
      <div class="pay-box">
        <div class="pay-demo">
          <img src="static/img/pay/pay-demo.png">
        </div>
        <div class="pay-qr-scan">
          <img src="static/img/pay/pay-qrscan.png">
          <div class="pay-tips" @click="payforOrder">
            <router-link to="/payDone"><p>点击我, 完成支付</p></router-link>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {PayForGoods} from '../api/order';

export default {
  name: 'Pay',
  data () {
    return {
      mes: [],
      cartGoodsIds: this.$route.query.cartGoodsIds,
      customerAddrId: this.$route.query.customerAddrId,
      point: this.$route.query.point
    };
  },
  methods: {
    payforOrder () {
      let payorder = {
        cartGoodsIds: this.cartGoodsIds,
        customerAddrId: this.customerAddrId,
        point: this.point
      };
      PayForGoods(payorder).then((res) => {
        // 处理类型
        // 获取用户订单
        if (res.data.code === '00000') {
          this.$Message.success(res.data.message);
          this.mes = res.data.data;
          console.log(this.mes.reason);
        } else {
          // this.$Message.error(res.data.message);
        }
      });
    }

  },
  mounted () {
  }
};
</script>

<style scoped>
.pay-container {
  margin: 15px auto;
  width: 80%;
  min-width: 1000px;
}
.pay-box {
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pay-demo {
  width: 50%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.pay-demo img{
  height: 80%;
}
.pay-qr-scan {
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.pay-tips {
  width: 50%;
  text-align: center;
  font-size: 14px;
  line-height: 30px;
}
.pay-tips a {
  color: #999999;
}
</style>
